package rmi;

import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Sets;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;


public class Client {

	public static void main(String[] args) throws RemoteException, MalformedURLException {
		try {
			Hello svc = (Hello) Naming.lookup("//localhost:6789/hello");
			System.out.println(svc.getClass().getClassLoader().getResource(""));
//			System.in.read();
			System.out.println(svc.hello("Lucy"));
			HelloTakeSetArg svc2 = (HelloTakeSetArg) Naming.lookup("//localhost:6789/hello2");
			System.out.println(svc2.hello(new JSONArray().fluentAddAll(Sets.newHashSet("Dido", "Taylor Swift"))));
			System.out.println(svc2.hello(Sets.newHashSet("Dido", "Taylor Swift")));
		} catch (NotBoundException | IOException e) {
			e.printStackTrace();
		}
	}
}
